package com.hejielife.singlethreadedexecution4;

/**
 * 2019年8月2日 上午10:30:41
 * 
 * @author hejielife
 * @despribe 互斥锁1
 */
public final class Mutex {
	private boolean busy = false;

	public synchronized void lock() {
		while (busy) {
			try {
				wait();
			} catch (InterruptedException e) {
			}
		}
		busy = true;
	}

	public synchronized void unlock() {
		busy = false;
		notifyAll();
	}
}
